package com.mc.lp.database.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author aphanda
 * 
 */

@Entity
@Table(name = "ACADEMIC_RECORD")
public class AcademicRecordEntity extends MicroCampusBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
	// @JoinColumn(name = "STUDENT_ENTITY_ID", insertable=false
	// ,updatable=false)
	@Column(name = "STUDENT_ENTITY_ID")
	private Long studentEntity;

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "SUBJECT_ID")
	private SubjectEntity subject;

	//@Convert(converter=TermTypeConverter.class)
	@Column(name = "TERM_ID")
	private int termId;

	@Column(name = "GRADE")
	private int gradeId;

	@Column(name = "YEAR")
	private Long year;

	@Column(name = "MARKS")
	private Long marks;

	@Column(name = "MAX_MARKS")
	private Long maxMarks;

	@Column(name = "GRADE_POINT")
	private int gradePointId;

	@Column(name = "REMARKS")
	private String remarks;
	
	@Column(name="ATTRIBUTE_WEIGHTAGE")
	private int attributeWeightage;

	public int getAttributeWeightage() {
		return attributeWeightage;
	}

	public void setAttributeWeightage(int attributeWeightage) {
		this.attributeWeightage = attributeWeightage;
	}

	public Long getStudentEntity() {
		return studentEntity;
	}

	public void setStudentEntity(Long studentEntity) {
		this.studentEntity = studentEntity;
	}

	public SubjectEntity getSubject() {
		return subject;
	}

	public void setSubject(SubjectEntity subject) {
		this.subject = subject;
	}

	public Long getMarks() {
		return marks;
	}

	public void setMarks(Long marks) {
		this.marks = marks;
	}

	public Long getMaxMarks() {
		return maxMarks;
	}

	public void setMaxMarks(Long maxMarks) {
		this.maxMarks = maxMarks;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public Long getYear() {
		return year;
	}

	public void setYear(Long year) {
		this.year = year;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	

	public int getTermId() {
		return termId;
	}

	public void setTermId(int termId) {
		this.termId = termId;
	}

	public int getGradeId() {
		return gradeId;
	}

	public void setGradeId(int gradeId) {
		this.gradeId = gradeId;
	}

	public int getGradePointId() {
		return gradePointId;
	}

	public void setGradePointId(int gradePointId) {
		this.gradePointId = gradePointId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = (int) prime * result + (gradeId);
		result = (int) (prime * result + (termId));
		result = (int) (prime * result + ((marks == null) ? 0 : marks));
		result = prime * result + ((remarks == null) ? 0 : remarks.hashCode());
		result = prime * result + ((subject == null) ? 0 : subject.hashCode());
		result = (int) (prime * result + (gradePointId));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		AcademicRecordEntity other = (AcademicRecordEntity) obj;
		if (gradeId != other.getGradeId()) {
			return false;
		}
		if (marks == null) {
			if (other.marks != null)
				return false;
		} else if (!marks.equals(other.marks))
			return false;
		if (remarks == null) {
			if (other.remarks != null)
				return false;
		} else if (!remarks.equals(other.remarks))
			return false;
		if (subject.getId() == null) {
			if (other.subject.getId() != null)
				return false;
		} else if (!subject.getId().equals(other.subject.getId()))
			return false;
		else if (!(this.gradePointId == other.getGradePointId())) {
			return false;
		}
		else if(this.termId != other.getTermId())
			return false;
		return true;
	}

}